/*
 * HttpPostDevice.h
 *
 *  Created on: 2012-11-7
 *      Author: minhua
 */

#ifndef HTTPPOSTDEVICE_H_
#define HTTPPOSTDEVICE_H_

#include <QIODevice>
#include <QFile>
#include <QHash>
#include <QString>
#include <QVariant>

struct PostFileContent
{
	QByteArray TopContent;
	QFile FileHandler;
	QByteArray BottomContent;
};

class HttpPostDevice : public QIODevice
{
	Q_OBJECT

// Member
private:
	QByteArray _variablesContent;
	QList<PostFileContent *> _fileContentList;
	QByteArray _endContent;
	qint64 _totalContentSize;
	QList<QIODevice *> _deviceList;
	qint64 _myPos;

// Method
public:
	HttpPostDevice(QHash<QString, QVariant> variables, QHash<QString, QString> files, QObject *parent = 0);
	virtual ~HttpPostDevice();
	virtual qint64 size() const;
	virtual qint64 readData(char *data, qint64 maxlen);
	virtual qint64 writeData(const char *data, qint64 len);
	virtual qint64 bytesAvailable() const;
	virtual bool atEnd() const;
};

#endif /* HTTPPOSTDEVICE_H_ */
